package mvp.com.bbc.ui.presenter;

import javax.inject.Inject;

import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.annotations.NonNull;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;
import mvp.com.bbc.appContact.AppContact;
import mvp.com.bbc.ui.model.ArtListClickModel;

/**
 * Created by ${cbf} on 2017/10/9.
 */

public class ArtListClickPresenter implements AppContact.ArtListClickPresenter {
    private AppContact.ArtListClickModel mClickModel;
    private AppContact.ArtListClickView mClickView;
    @Inject
    public ArtListClickPresenter(AppContact.ArtListClickView clickView) {
        mClickView = clickView;
        mClickModel = new ArtListClickModel();
    }

    @Override
    public void artListClickPresenter(String articleid, String userid, String status) {
        mClickModel.artListClickModel(articleid, userid, status)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeOn(Schedulers.io())
                .subscribe(new Observer<String>() {
                    @Override
                    public void onSubscribe(@NonNull Disposable d) {

                    }

                    @Override
                    public void onNext(@NonNull String s) {
                        mClickView.artListClickView(s);
                    }

                    @Override
                    public void onError(@NonNull Throwable e) {

                    }

                    @Override
                    public void onComplete() {

                    }
                });
    }
}
